<?php
define('NEED_PERMISSION','CSR_OR_PHOTO');
include '_init_.php';
	$orderManager = Order_Manager::getOrderManager($_REQUEST['id']);
if($orderManager == null)
	exit("Not exist");
if($orderManager->getStatus() != Order_Manager::$STATUS_SAVED)
	exit("Not allowed");
$orderManager->init();
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
if($act == 'save')
{
	$setInfo = array();
	$setInfo['photo_time'] = strlen($_REQUEST['photo_time']) > 0?$_REQUEST['photo_time'].' '.$_REQUEST['photo_time_time']:'';
	$setInfo['proof_time'] = strlen($_REQUEST['proof_time']) > 0?$_REQUEST['proof_time'].' '.$_REQUEST['proof_time_time']:'';
	$setInfo['pickup_time'] = strlen($_REQUEST['pickup_time']) > 0?$_REQUEST['pickup_time'].' '.$_REQUEST['pickup_time_time']:'';
	$setInfo['photo_person_list'] = isset($_REQUEST['photo_person_list'])?$_REQUEST['photo_person_list']:array();
	$setInfo['dress_person_list'] = isset($_REQUEST['dress_person_list'])?$_REQUEST['dress_person_list']:array();
	$setInfo['csr_list'] = isset($_REQUEST['csr_list'])?$_REQUEST['csr_list']:array();
	$setInfo['pickup_person_list'] = isset($_REQUEST['pickup_person_list'])?$_REQUEST['pickup_person_list']:array();
	$orderManager->setWorkflowInfo($setInfo);
	$orderManager->persistOrderInfo();
	AppMain::refreshParentFrame();
}
$pageInfo = $orderManager->getWorkflowInfo();

$pageInfo['photo_time'] = trim($pageInfo['photo_time']);
$pageInfo['proof_time'] = trim($pageInfo['proof_time']);
$pageInfo['pickup_time'] = trim($pageInfo['pickup_time']);

if(isset($pageInfo['photo_time']) && strlen($pageInfo['photo_time']) > 0)
{
	$objDatetime = strtotime($pageInfo['photo_time']);
	$pageInfo['photo_time'] = date(constant('WEBSITE_DATE_FORMATE'),$objDatetime);
	$pageInfo['photo_time_time'] = date('H:00:00',$objDatetime);
}

if(isset($pageInfo['proof_time']) && strlen($pageInfo['proof_time']) > 0)
{
	$objDatetime = strtotime($pageInfo['proof_time']);
	$pageInfo['proof_time'] = date(constant('WEBSITE_DATE_FORMATE'),$objDatetime);
	$pageInfo['proof_time_time'] = date('H:00:00',$objDatetime);

}
if(isset($pageInfo['pickup_time']) && strlen($pageInfo['pickup_time']) > 0)
{
		$objDatetime = strtotime($pageInfo['pickup_time']);
	$pageInfo['pickup_time'] = date(constant('WEBSITE_DATE_FORMATE'),$objDatetime);
	$pageInfo['pickup_time_time'] = date('H:00:00',$objDatetime);

}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script language="javascript" src="js/jquery-ui-datepicker.min.js"></script>
<link href="css/smoothness/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<script language="javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat: 'yy/mm/dd'});
});
</script>

<script language="javascript">
$(function() {
	//apply data
	$('input[name=photo_time]').val('<?php echo $pageInfo['photo_time'];?>');
	$('input[name=proof_time]').val('<?php echo $pageInfo['proof_time'];?>');
	$('input[name=pickup_time]').val('<?php echo $pageInfo['pickup_time'];?>');
	
	$('select[name=photo_time_time] option[value="<?php if(isset($pageInfo['photo_time_time'])) {echo $pageInfo['photo_time_time'];}?>"]').attr('selected',true);
	$('select[name=proof_time_time] option[value="<?php if(isset($pageInfo['proof_time_time'])) {echo $pageInfo['proof_time_time'];}?>"]').attr('selected',true);
	$('select[name=pickup_time_time] option[value="<?php if(isset($pageInfo['pickup_time_time'])) {echo $pageInfo['pickup_time_time'];}?>"]').attr('selected',true);
	
	<?php foreach($pageInfo['photo_person_list'] as $tmpData):?>
	<?php if(strlen(trim($tmpData)) > 0):?>
	$('.jq_html_selector_photo[value="<?php echo $tmpData;?>"]').attr('checked',true);
	<?php endif;?>
	
	<?php endforeach;?>
	<?php foreach($pageInfo['dress_person_list'] as $tmpData):?>
	<?php if(strlen(trim($tmpData)) > 0):?>
	$('.jq_html_selector_dress[value="<?php echo $tmpData;?>"]').attr('checked',true);
	<?php endif;?>
	<?php endforeach;?>
	
	<?php foreach($pageInfo['csr_list'] as $tmpData):?>
	<?php if(strlen(trim($tmpData)) > 0):?>
	$('.jq_html_selector_csr_list[value="<?php echo $tmpData;?>"]').attr('checked',true);
	<?php endif;?>
	<?php endforeach;?>
	
	<?php foreach($pageInfo['pickup_person_list'] as $tmpData):?>
	<?php if(strlen(trim($tmpData)) > 0):?>
	$('.jq_html_selector_pickup_list[value="<?php echo $tmpData;?>"]').attr('checked',true);
	<?php endif;?>
	<?php endforeach;?>
});
</script>
</head>

<body>
<form action="cosij.php">
<input type="hidden" name="act" value="save"/>
<input type="hidden" name="id" value="<?php echo $orderManager->getId();?>"/>
<div class="mainf-8">
  <ul>
        <li class="maina-1f">拍照<img src="images/line3.gif" width="21" height="12" />
        <input name="photo_time" type="text"  class="datepicker maine-keyini2"/> 
        <select name="photo_time_time" class="maine-keyinm" >
        <option value="9:00:00">AM 9:00</option>
         <option value="10:00:00">AM 10:00</option>
         <option value="11:00:00">AM 11:00</option>
         <option value="12:00:00">PM 12:00</option>
         <option value="13:00:00">PM 1:00</option>
         <option value="14:00:00">PM 2:00</option>
         <option value="15:00:00">PM 3:00</option>
         <option value="16:00:00">PM 4:00</option>
         <option value="17:00:00">PM 5:00</option>
         <option value="18:00:00">PM 6:00</option>
       </select>
       </li>
        <li class="maina-1f2">攝影師</li>
          <?php
      	$dtWorder = new DataTable(constant('DB_TABLE_WORKER'));
      	$workerList = $dtWorder->get_list('`type`=4','name');
      	foreach($workerList as $tmpData)
      	{
      ?>
      	<li class="mainf-1c"><input type="checkbox" class="jq_html_selector_photo" name="photo_person_list[]" value="<?php echo $tmpData['name'];?>"/>&nbsp;<?php echo $tmpData['name'];?></li>
      <?php }?>

      
       <li class="maina-1f2">造型師</li>
       <?php
      	$dtWorder = new DataTable(constant('DB_TABLE_WORKER'));
      	$workerList = $dtWorder->get_list('`type`=5','name');
      	foreach($workerList as $tmpData)
      	{
      ?>
      	<li class="mainf-1c"><input type="checkbox" class="jq_html_selector_dress" name="dress_person_list[]" value="<?php echo $tmpData['name'];?>"/>&nbsp;<?php echo $tmpData['name'];?></li>
      <?php }?>

      
      <li class="maina-1f">看樣<img src="images/line3.gif" width="21" height="12" />
      <input name="proof_time" type="text"  class="maine-keyini2 datepicker"/>
      <select name="proof_time_time" class="maine-keyinm"  >
         <option value="9:00:00">AM 9:00</option>
         <option value="10:00:00">AM 10:00</option>
         <option value="11:00:00">AM 11:00</option>
         <option value="12:00:00">PM 12:00</option>
         <option value="13:00:00">PM 1:00</option>
         <option value="14:00:00">PM 2:00</option>
         <option value="15:00:00">PM 3:00</option>
         <option value="16:00:00">PM 4:00</option>
         <option value="17:00:00">PM 5:00</option>
         <option value="18:00:00">PM 6:00</option>
       </select>
       </li>
      
      <li class="maina-1f2">客服部</li>
      <?php
      	$dtWorder = new DataTable(constant('DB_TABLE_WORKER'));
      	$workerList = $dtWorder->get_list('`type`=2','name');
      	foreach($workerList as $tmpData)
      	{
      ?>
      	<li class="mainf-1c"><input type="checkbox" class="jq_html_selector_csr_list" name="csr_list[]" value="<?php echo $tmpData['name'];?>"/>&nbsp;<?php echo $tmpData['name'];?></li>
      <?php }?>

      
      <li class="maina-1f">取件<img src="images/line3.gif" width="21" height="12" />
      <input name="pickup_time" type="text"  class="maine-keyini2 datepicker"/>
      <select name="pickup_time_time" class="maine-keyinm">
         <option value="9:00:00">AM 9:00</option>
         <option value="10:00:00">AM 10:00</option>
         <option value="11:00:00">AM 11:00</option>
         <option value="12:00:00">PM 12:00</option>
         <option value="13:00:00">PM 1:00</option>
         <option value="14:00:00">PM 2:00</option>
         <option value="15:00:00">PM 3:00</option>
         <option value="16:00:00">PM 4:00</option>
         <option value="17:00:00">PM 5:00</option>
         <option value="18:00:00">PM 6:00</option>
       </select>
       </li>
      
      <li class="maina-1f2">客服部</li>
        <?php
      	$dtWorder = new DataTable(constant('DB_TABLE_WORKER'));
      	$workerList = $dtWorder->get_list('`type`=2','name');
      	foreach($workerList as $tmpData)
      	{
      ?>
      	<li class="mainf-1c"><input type="checkbox" class="jq_html_selector_pickup_list" name="pickup_person_list[]" value="<?php echo $tmpData['name'];?>"/>&nbsp;<?php echo $tmpData['name'];?></li>
      <?php }?>
  </ul>
</div>

<div class="mainf-7">
<ul>
<li class="article-1g"><input name="" type="button" class="article-1a_btn" value="儲存" onclick="document.forms[0].submit();return false;"/></li>
</ul>
</div>
</form>
</body>
</html>
